#include <stdio.h>
#include <stdlib.h>

typedef struct node
{
    int data;
    struct node* next;
}LNode;

void Slistpushback(LNode** head,int x)
{
    LNode *newnode;
    LNode *tail;
    tail=*head;
    newnode=(LNode*)malloc(sizeof(LNode));
    newnode->data=x;
    newnode->next=NULL;
    if(*head==NULL)
    {
        *head=newnode;
    }
    else
    {
        while(tail->next!=NULL)
        {
            tail=tail->next;
        }
        tail->next=newnode;
    }
}
void Slistin(LNode** phead,int y)
{
    LNode* newnode;
    newnode=(LNode*)malloc(sizeof(LNode));
    int f=1;
    newnode->data=y;
    if((*phead)->data>=y)
    {
        newnode->next=*phead;
        *phead=newnode;
        f=0;
    }
    LNode* cur=(*phead)->next;
    LNode* prev=*phead;
    while(cur!=NULL&&f)
    {
        if(cur->data>=y&&prev->data<=y)
        {
            newnode->next=cur;
            prev->next=newnode;
            break;
        }
        prev=cur;
        cur=cur->next;
    }
    if(cur==NULL)
    {
        newnode->next=cur;
        prev->next=newnode;
    }
}
int main()
{
    int n,x;
    while(scanf("%d",&n)!=EOF)
    {
        LNode* plist;
        plist=NULL;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&x);
            if(i==0)
            Slistpushback(&plist,x);
            else
            Slistin(&plist,x);
        }
        LNode* tail=plist;
        while(tail!=NULL)
        {
            printf("%d  ",tail->data);
            tail=tail->next;
        }
        printf("\n");
    }
    return 0;
}
